package com.ruoyi.manage.service.impl;

import java.util.List;

import com.ruoyi.common.core.cg.pojo.Classification;
import com.ruoyi.manage.mapper.ClassificationMapper;
import com.ruoyi.manage.service.IClassificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 分类Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-10
 */
@Service
public class ClassificationServiceImpl implements IClassificationService
{
    @Autowired
    private ClassificationMapper classificationMapper;

    /**
     * 查询分类
     *
     * @param fId 分类主键
     * @return 分类
     */
    @Override
    public Classification selectClassificationByFId(Long fId)
    {
        return classificationMapper.selectClassificationByFId(fId);
    }

    /**
     * 查询分类列表
     *
     * @param classification 分类
     * @return 分类
     */
    @Override
    public List<Classification> selectClassificationList(Classification classification)
    {
        List<Classification> classifications = classificationMapper.selectClassificationList(classification);
        for (Classification classification1 : classifications) {
            classification1.setfNun(classificationMapper.selectCount(classification1.getfId()));
        }
        return classifications;
    }

    /**
     * 新增分类
     *
     * @param classification 分类
     * @return 结果
     */
    @Override
    public int insertClassification(Classification classification)
    {
        return classificationMapper.insertClassification(classification);
    }

    /**
     * 修改分类
     *
     * @param classification 分类
     * @return 结果
     */
    @Override
    public int updateClassification(Classification classification)
    {
        return classificationMapper.updateClassification(classification);
    }

    /**
     * 批量删除分类
     *
     * @param fIds 需要删除的分类主键
     * @return 结果
     */
    @Override
    public int deleteClassificationByFIds(Long[] fIds)
    {
        return classificationMapper.deleteClassificationByFIds(fIds);
    }

    /**
     * 删除分类信息
     *
     * @param fId 分类主键
     * @return 结果
     */
    @Override
    public int deleteClassificationByFId(Long fId)
    {
        return classificationMapper.deleteClassificationByFId(fId);
    }
}
